# 需要优先引入settings
from . import settings
from flask import Flask
from flask_cors import *


def create_app():
    from .apis import (
        dining,
        dish,
        order,
        stall,
        user,
        server,
        order,
        synUpdate,
        stats
    )
    from . import metrics
    from . import db
    app = Flask(__name__)
    app.config['JSON_AS_ASCII'] = False
    CORS(app, supports_cordentials=True)
    metrics.init_app(app)
    db.init_app(app)
    # apis
    dining.init_app(app)
    dish.init_app(app)
    order.init_app(app)
    stall.init_app(app)
    user.init_app(app)
    server.init_app(app)
    order.init_app(app)
    synUpdate.init_app(app)
    stats.init_app(app)
    return app
